package com.mj.activity;

import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;

import com.mj.R;
import com.mj.base.BaseActivity;

public class Activity_Paixu extends BaseActivity {
	@Override
	protected void onCreate(Bundle arg0) {
		super.onCreate(arg0);
		setContentView(R.layout.activity_paixu);
		init();
	}

	private void init() {
		// title
		aq.id(R.id.btn_left).background(R.color.none).text("取消").clicked(this, "back");
		aq.id(R.id.btn_right).background(R.color.none).text("确定").clicked(this, "back");
		aq.id(R.id.tv_title).text("排序");
		ViewGroup group = (ViewGroup) findViewById(R.id.ll_group);
		int childCount = group.getChildCount();
		for (int a = 0; a < childCount; a++) {
			View v = group.getChildAt(a);
			v.setTag(a);
			v.setOnClickListener(new OnClickListener() {
				@Override
				public void onClick(View v) {
					changeType(v);
				}
			});
		}
	}

	/**
	 * 根据选择修改图片
	 * 
	 * @param view
	 * @param num
	 *            数量
	 * @param position
	 *            位置
	 */
	private void changeType(View view) {
		ViewGroup group = (ViewGroup) view.getParent();
		int childCount = group.getChildCount();
		for (int a = 0; a < childCount; a++) {
			View v = group.getChildAt(a);
			aq.id(v.findViewById(R.id.imageView1)).image(R.drawable.check_n);
		}
		aq.id(view.findViewById(R.id.imageView1)).image(R.drawable.check_p);
	}
}
